package dahua_design.model1_00;

import java.util.Scanner;

/**
 * @ClassName: Calculator
 * @Description: 计算器类-原始实现
 * @Version: v1.0.0
 * @Author: tamir
 * @Date: 2022/05/26
 * Modification History:
 * Date             Author      Version     Description
 * -------------------------------------------------------------
 * 2022/05/26      tamir        v1.0.0      创建
 */
public class Calculator {
	public static void main(String[] args) {
		System.out.println("输入第一个值：");
		Scanner inp = new Scanner(System.in);
		Integer num1 = inp.nextInt();
		System.out.println("输入字符串：");
		Scanner inp2 = new Scanner(System.in);
		String op = inp2.nextLine();
		System.out.println("输入第二个数：");
		Scanner inp3 = new Scanner(System.in);
		Integer num2 = inp3.nextInt();
		Integer res = null;
		switch (op) {
			case "+":
				res = num1 + num2;
				break;
			case "-":
				res = num1 - num2;
				break;
			case "*":
				res = num1 * num2;
				break;
			case "/":
				if (num2 != 0) {
					res = num1 / num2;
				} else {
					System.out.println("除数不能为0");
				}
				break;
			default:
				break;
		}
		System.out.println("最后结果为"+res);
	}
}
